<script type="text/javascript">
    $(document).ready(function(){
    var i = $('#new_item').val();
    var j = $('#best_selling').val();
    if(i == 1)
         $('#new_image_area').show('low');
    if(j == 1)
         $('#best_selling_area').show('low');
     
     $('#simple_form').submit(function(){
        var catselected = $('select[name="category_id"] option:selected').val();//console.log(catselected);
        if(catselected == 0)
        {
            alert('Không được chọn danh mục gốc!');
            return false;
        }
        return true;
    })
    });
    
</script>
{{if validation_errors()}}
<ul class="message error">
    <li>{{validation_errors()}}</li>
</ul>
{{/if}}

<div class="clear"></div>
<form class="block-content form" id="simple_form" method="post" action="create">
<h1>{{$news->lang->line('news')}}</h1>
<ul class="tabs js-tabs same-height">
    <li class="current"><a href="#tab-locales" title="Locales">{{$news->lang->line('current')}}</a></li>
    <li><a href="#tab-options" title="Options">{{$news->lang->line('options')}}</a></li>    
    <li><a href="#tab-seo" title="Seo">{{$news->lang->line('seo')}}</a> </li>
</ul>

<div class="tabs-content">    
        <div id="tab-locales">
            {{if isset($news->id)}}{{form_hidden('id', $news->id)}}{{/if}}
            <fieldset class="grey-bg required">			
                <legend>{{$news->lang->line('required')}}</legend>
                <p>
                    <label for="simple-required">{{$news->lang->line('news')}}</label>
                    
                    <input type="text" name="title" id="simple-required" value="{{if isset($news->title)}}{{$news->title}}{{/if}}" class="full-width">
                    {{form_error('title')}}
                </p>
            </fieldset>
            <fieldset>
                <legend>{{$news->lang->line('other_info')}}</legend>
                <p>
                    <label for="description">{{$news->lang->line('description')}}</label>
                    <textarea name="description" cols="10" class="full-width text-editor">{{if isset($news->description)}}{{$news->description}}{{/if}}</textarea>
                </p>

                <p>
                    <label for="content">{{$news->lang->line('content')}}</label>
                    <textarea name="content" cols="10" class="full-width text-content tinymcefull">{{if isset($news->content)}}{{$news->content}}{{/if}}</textarea>
                </p>
                
                <p>
                    {{if !isset($news->sub_content)}}
                    <script>
                        $(document).ready(function(){
                            var html = '<div class="my-box col_1">';
                            html += '<h2>Điểm nổi bật</h2><p>Điểm nổi bật 1.</p><p>Điểm nổi bật 2.</p><p>Điểm nổi bật 3.</p></div>';
                            html += '<div class="my-box col_2">';
                            html += '<h2>Điều kiện</h2><p>Điều kiện 1.</p><p>Điều kiện 2.</p><p>Điều kiện 3.</p></div>';
                            $("#sub-content").val(html);
                        })
                    </script>
                    {{/if}}
                    <label for="content">{{$news->lang->line('sub_content')}}</label>
                    <textarea name="sub_content" id="sub-content" cols="10" class="full-width text-content tinymcesimple">{{if isset($news->sub_content)}}{{$news->sub_content}}{{/if}}</textarea>
                </p>
                
                <p>
                    <label for="simple-select">{{$news->lang->line('cat')}}</label>
                    <select name="category_id" id="simple-select" class="full-width">
                        {{html_options options=$category_list selected=$news->category_id}} 
                    </select>
                </p>
                <!--<p>
                    <label for="simple-select">{{$news->lang->line('position')}}</label>
                    <select name="feature" id="simple-select" class="full-width">                      
                        {{html_options options=$news->feature_list() selected=$news->feature}}                   
                    </select>
                </p>-->


            </fieldset>
        </div>
        <div id="tab-options">
            <fieldset>
                <legend>Giá sản phẩm</legend>
                <p>
                    <label for="new_price">{{$news->lang->line('new_price')}}</label>
                    <input type="text" name="new_price" cols="10" class="full-width" value="{{if isset($news->new_price)}}{{$news->new_price}}{{/if}}"/>
                </p>

                <p>
                    <label for="old_price">{{$news->lang->line('old_price')}}</label>
                    <input type="text" name="old_price" cols="10" class="full-width" value="{{if isset($news->old_price)}}{{$news->old_price}}{{/if}}"/>
                </p>
            </fieldset>
            
            <fieldset>
                <legend>Custom sản phẩm mới/hot</legend>
                <p>
                    <label for="simple-select">{{$news->localize_label('new_item')}}</label>
                    <select name="new_item" id="new_item" class="full-width" onchange="javascript:change_option('new_item','new_image_area');">
                        {{html_options options=$news->new_item_list() selected=$news->new_item}}
                    </select>
                </p>
                <p id="new_image_area" style="display: none;">
                    <label for="image">{{$news->localize_label('new_image')}}</label>				
                    <input type="text" name="new_image" id="new_image" class="full-width" ondblclick="javascript:imagemanager('new_image');" value="{{if isset($news->new_image)}}{{$news->new_image}}{{/if}}">
                </p>

                <p>
                    <label for="simple-select">{{$news->localize_label('best_selling')}}</label>
                    <select name="best_selling" id="best_selling" class="full-width" onchange="javascript:change_option('best_selling','best_selling_area');">
                        {{html_options options=$news->best_selling_list() selected=$news->best_selling}}
                    </select>
                </p>
                <p id="best_selling_area" style="display: none;">
                    <label for="image">{{$news->localize_label('best_selling_image')}}</label>				
                    <input type="text" name="best_selling_image" id="best_selling_image" class="full-width" ondblclick="javascript:imagemanager('best_selling_image');" value="{{if isset($news->best_selling_image)}}{{$news->best_selling_image}}{{/if}}">				
                </p>
            </fieldset>
            <!--<fieldset>
                <legend>Sản phẩm xuất hiện trên menu mới/bán chạy</legend>
                <p style="float: left">
                    <label style="display: inline">Cập nhật sản phẩm mới</label>
                    <input style="margin-left: 5px;" type="checkbox" />
                </p>
                <p style="margin-left: 200px">
                    <label style="display: inline">Cập nhật sản phẩm bán chạy</label>
                    <input style="margin-left: 5px" type="checkbox" />
                </p>
            </fieldset>-->
            <fieldset>
                <legend>Hình ảnh cho sản phẩm</legend>
                <p>
                    <label for="image">{{$news->localize_label('image')}}</label>				
                    <input type="text" name="image" id="image" class="full-width" value="{{if isset($news->image)}}{{$news->image}}{{/if}}" ondblclick="javascript:imagemanager('image');">
                </p>
                <p>
                    <label for="image">{{$news->localize_label('img_detail_1')}}</label>				
                    <input type="text" name="img_detail_1" id="img_detail_1" class="full-width" value="{{if isset($news->img_detail_1)}}{{$news->img_detail_1}}{{/if}}" ondblclick="javascript:imagemanager('img_detail_1');">
                </p>
                <p>
                    <label for="image">{{$news->localize_label('img_detail_2')}}</label>				
                    <input type="text" name="img_detail_2" id="img_detail_2" class="full-width" value="{{if isset($news->img_detail_2)}}{{$news->img_detail_2}}{{/if}}" ondblclick="javascript:imagemanager('img_detail_2');">
                </p>
                <p>
                    <label for="image">{{$news->localize_label('img_detail_3')}}</label>				
                    <input type="text" name="img_detail_3" id="img_detail_3" class="full-width" value="{{if isset($news->img_detail_3)}}{{$news->img_detail_3}}{{/if}}" ondblclick="javascript:imagemanager('img_detail_3');">
                </p>
            </fieldset>
            
            <p>
                <label for="simple-select">{{$news->localize_label('url_target')}}</label>
                <select name="url_target" id="simple-select" class="full-width">				
                    {{html_options options=$news->url_target_list() selected=$news->url_target}}
                </select>
            </p>
            <!--<p>
                <label for="link">{{$news->lang->line('link')}}</label>				
                <input type="text" name="link" class="full-width" value="{{if isset($news->link)}}{{$news->link}}{{/if}}">				
            </p>

            <p>
                <label for="simple-select">{{$news->lang->line('partner')}}</label>
                <select name="partner_id" id="simple-select" class="full-width">
                    {{html_options options=$partner->get_list() selected=$news->partner_id}}
                </select>
            </p>
            <p>
                <label for="simple-select">{{$news->lang->line('language')}}</label>
                <select name="lang_id" id="simple-select" class="full-width">
                     {{html_options options=$language->get_list() selected=$news->language_id}}
                </select>
            </p>
            
            <p>
                <label for="image">{{$news->lang->line('creator')}}</label>				
                <input type="text" name="creator" class="full-width" value="">				
            </p>-->

            <div class="columns">
                <div class="colx2-left">
                    <label for="content">{{$news->lang->line('simple-calendar')}}</label>
                    <span class="input-type-text margin-right relative">
                        <input type="text" name="simple-calendar" id="simple-calendar" value="">
                        <img src="{{base_url()}}data/templates/backend/xgo/images/icons/fugue/calendar-month.png" width="16" height="16">
                    </span> 

                </div>
                <p class="colx2-right">					
                    <label for="active">{{$news->lang->line('active')}}</label>
                    <input type="checkbox" name="active" id="simple-switch-on" value="1" checked="checked" class="switch" onclick="$(this).setActive();">
                </p>
            </div>
            
            <div class="columns">
                <div class="colx2-left">
                    <label for="active">{{$news->lang->line('viewed')}}<b>1002</b></label>
                </div>
                <p class="colx2-right">					
                    <label for="active">{{$news->localize_label('updated')}}<b>{{if isset($news->updated)}}{{$news->updated}}{{/if}}</b></label>
                </p>
            </div>            
        </div>
        <div id="tab-seo">            
            <p>
                <label for="active">{{$news->lang->line('seo_title')}}</label>
                <input type="text" name="seo_title" class="full-width" value="{{if isset($news->seo_title)}}{{$news->seo_title}}{{/if}}">				
            </p>
            <p>
                <label for="keyword">{{$news->lang->line('keyword')}}</label>
                <input type="text" name="keyword" class="full-width" value="{{if isset($news->seo_title)}}{{$news->seo_title}}{{/if}}">				
            </p>
            <p>
                <label for="metadata">{{$news->lang->line('metadata')}}</label>
                <textarea name="metadata" cols="10" class="full-width text-editor tinymcesimple">{{if isset($news->metadata)}}{{$news->metadata}}{{/if}}</textarea>
            </p>
        </div>
        <br/><br/><br/><br/><br/>  
        <fieldset class="grey-bg no-margin">
            <legend>{{$news->lang->line('action')}}</legend>
            <p class="input-with-button">
                <button type="submit">{{$news->lang->line('save')}}</button>
                <button style="float:right" type="button" onclick="window.history.back()">{{$news->lang->line('back')}}</button>
            </p>
        </fieldset>				
	</div>
</form>
